package com.luocj.refresh.adapter;

import android.content.Context;
import android.util.Log;

import com.chad.library.adapter.base.BaseMultiItemQuickAdapter;
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.luocj.refresh.R;
import com.luocj.refresh.model.MultiModel;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by Administrator on 2018/2/9/009.
 */

public class GridItemAdapter extends BaseMultiItemQuickAdapter<MultiModel, BaseViewHolder> {

    private List<MultiModel> models;
    private Context mContext;

    public GridItemAdapter(Context context, List<MultiModel> data) {
        super(data);
        this.models = data;
        this.mContext = context;

        Log.i(TAG, "GridItemAdapter: " + models.size());
//
//        addItemType(MultiModel.TYPE_TEXT, R.layout.type_one);
        addItemType(MultiModel.TYPE_TEXT, R.layout.item_text);
        addItemType(MultiModel.TYPE_TEXT_IMAGE, R.layout.item_text_image);

    }

    @Override
    protected void convert(BaseViewHolder holder, MultiModel item) {
        int itemViewType = holder.getItemViewType();
        switch (itemViewType) {
            case MultiModel.TYPE_TEXT:
                holder.setText(R.id.tv_content, "text" + item.getSpanSize() + "");
                break;
            case MultiModel.TYPE_TEXT_IMAGE:
                holder.setText(R.id.tv_type_three, "text_image" + item.getSpanSize() + "");
                break;
        }
    }
}
